#include <bits/stdc++.h>
using namespace std;
int stu[1000001];

int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++)
    cin >> stu[i];
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    int w = stu[i];
    if (stu[w] == i) {
        ans++;
    }
  }
  cout << ans/2;

  return 0;
}